package com.psa.tool;

import android.os.AsyncTask;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author david
 * @date 2015-07-07
 */
public class TaskManager {
    private static TaskManager taskManager;
    private ArrayList<AsyncTask> tasks = null;
    private boolean running = false;
    private List<IGeneralEventCallback> eventCallbacks = null;

    public void addGeneralEventListener(IGeneralEventCallback generalEventCallback){
        if (!eventCallbacks.contains(generalEventCallback)) {
            eventCallbacks.add(generalEventCallback);
        }
    }

    public void removeGeneralEventListener(IGeneralEventCallback generalEventCallback){
        if (eventCallbacks.contains(generalEventCallback)) {
            eventCallbacks.remove(generalEventCallback);
        }
    }

    private TaskManager(){
        tasks = new ArrayList<AsyncTask>();
        eventCallbacks = new ArrayList<IGeneralEventCallback>();
    }

    public static TaskManager getTaskManager(){
        if (taskManager==null) {
            taskManager = new TaskManager();
        }
        return taskManager;
    }
}
